<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>设置-个人信息</title>
    <link rel="icon" href="/assets/img/favicon.ico">

    <link rel="stylesheet" type="text/css" href="css/webbase.css"/>
    <link rel="stylesheet" type="text/css" href="css/pages-seckillOrder.css"/>
</head>

<body>
<!--页面顶部白条条，由js动态加载-->
<script type="text/javascript" src="plugins/jquery/jquery.min.js"></script>
<div class="nav-bottom"></div>
<script type="text/javascript">$(".nav-bottom").load("top.html");</script>

<script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#service").hover(function () {
            $(".service").show();
        }, function () {
            $(".service").hide();
        });
        $("#shopcar").hover(function () {
            $("#shopcarlist").show();
        }, function () {
            $("#shopcarlist").hide();
        });

    })
</script>
<script type="text/javascript" src="js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="js/widget/nav.js"></script>
<script type="text/javascript" src="js/plugins/birthday/birthday.js"></script>
<script type="text/javascript" src="js/plugins/citypicker/distpicker.data.js"></script>
<script type="text/javascript" src="js/plugins/citypicker/distpicker.js"></script>
<script type="text/javascript" src="js/plugins/upload/uploadPreview.js"></script>
<script type="text/javascript" src="js/pages/main.js"></script>
<script>
    $(function () {
        $.ms_DatePicker({
            YearSelector: "#select_year2",
            MonthSelector: "#select_month2",
            DaySelector: "#select_day2"
        });
    });
</script>
</body>
<!--header-->
<div id="account">
    <div class="py-container">
        <div class="yui3-g home">
            <!--左侧列表-->
            <div class="yui3-u-1-6 list">

                <div class="person-info">
                    <div class="person-photo"><img src="img/_/photo.png" alt=""></div>
                    <div class="person-account">
                        <span class="name">Michelle</span>
                        <span class="safe">账户安全</span>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="list-items">
                    <dl>
                        <dt><i>·</i> 订单中心</dt>
                        <dd><a href="home-index.html">我的订单</a></dd>
                        <dd><a href="home-order-pay.html">待付款</a></dd>
                        <dd><a href="home-order-send.html">待发货</a></dd>
                        <dd><a href="home-order-receive.html">待收货</a></dd>
                        <dd><a href="home-order-evaluate.html">待评价</a></dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 我的中心</dt>
                        <dd><a href="home-person-collect.html">我的收藏</a></dd>
                        <dd><a href="home-person-footmark.html">我的足迹</a></dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 物流消息</dt>
                    </dl>
                    <dl>
                        <dt><i>·</i> 设置</dt>
                        <dd><a href="home-setting-info.html" class="list-active">个人信息</a></dd>
                        <dd><a href="home-setting-address.html">地址管理</a></dd>
                        <dd><a href="home-setting-safe.html">安全管理</a></dd>
                    </dl>
                </div>
            </div>
            <!--右侧主内容-->
            <div class="yui3-u-5-6">
                <div class="body userInfo">
                    <ul class="sui-nav nav-tabs nav-large nav-primary ">
                        <li class="active">
                            <a href="#one" data-toggle="tab">基本资料</a>
                        </li>
                        <li>
                            <a href="#two" data-toggle="tab">头像照片</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="one" class="tab-pane active">
                            <form id="form-msg" class="sui-form form-horizontal">
                                <div class="control-group">
                                    <label for="inputName" class="control-label">昵称：</label>
                                    <div class="controls">
                                        <input type="text" placeholder="请输入你的用户名" class="input-xfat input-xlarge"
                                               v-model="user.nickname" name="nickname" data-vv-as="昵称"
                                               v-validate="'required|alpha_dash|min:4|max:30|useful:1'">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="inputGender" class="control-label">性别：</label>
                                    <div class="controls">
                                        <label data-toggle="radio" class="radio-pretty inline"
                                               :class="{checked:user.sex==1}">
                                            <input type="radio" name="sex" value="1" v-model="user.sex"><span>男</span>
                                        </label>
                                        <label data-toggle="radio" class="radio-pretty inline"
                                               :class="{checked:user.sex==2}">
                                            <input type="radio" name="sex" value="2" v-model="user.sex"><span>女</span>
                                        </label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="inputPassword" class="control-label">生日：</label>
                                    <div class="controls">
                                        <select id="select_year2" rel="1990" v-model="a"
                                                ></select>年
                                        <select id="select_month2" rel="4" v-model="b"></select>月
                                        <select id="select_day2" rel="3" v-model="c"></select>日
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label for="inputPassword" class="control-label">所在地：</label>
                                    <div class="controls">
                                        <div data-toggle="distpicker">
                                            <div class="form-group area">
                                                <select class="form-control" id="province1" v-model="d"></select>
                                            </div>
                                            <div class="form-group area">
                                                <select class="form-control" id="city1" v-model="e"></select>
                                            </div>
                                            <div class="form-group area">
                                                <select class="form-control" id="district1" v-model="g"></select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">职业：</label>
                                    <div class="controls"><span class="sui-dropdown dropdown-bordered select"><span
                                            class="dropdown-inner"><a role="button" data-toggle="dropdown" href="#"
                                                                      class="dropdown-toggle">
                                                <input name="job" type="hidden" data-rules="required"><i
                                            class="caret"></i><span>{{user.job || '请选择'}}</span></a>
                                            <ul id="menu4" role="menu" aria-labelledby="drop4"
                                                class="sui-dropdown-menu">
                                                <li role="presentation" v-for="(j,k) in job" :key="k" >
                                                    <a role="menuitem" @click="changJob(j)" href="javascript:void(0);">
                                                        {{j}}
                                                    </a>
                                                </li>
                                            </ul>
                                            </span>
                                            </span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="sanwei" class="control-label"></label>
                                    <div class="controls">
                                        <button type="button"  @click="submit123" class="sui-btn btn-primary">立即注册</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div id="two" class="tab-pane">
                            <div class="new-photo">
                                <p>当前头像：</p>
                                <div class="upload">
                                    <img id="imgShow_WU_FILE_0" width="100" height="100" src="img/_/photo_icon.png"
                                         alt="">
                                    <input type="file" id="up_img_WU_FILE_0"/>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script src="./js/vue/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/common.js"></script>
<script type="text/javascript">
     new Vue({
        el: "#form-msg",
        data: {
            ly,
            job: ['程序员', '产品经理', 'UI设计师'],
            user: {
                nickname: '',
                sex: '',
                birthday: '',
                address: '',
                job: '',
                pic: '',
            },
            a: '',
            b: '',
            c: '',
            d: '',
            e: '',
            g: '',

        },
        created() {
            //重新加载用户个人信息
            this.action();


        },
        methods: {
            changJob(job) {
                console.log(job)
                this.user.job = job;
                console.log(this.user.job)
            },
            submit123() {
                // 判断是否登录
                ly.http.get('/auth/verify').then(() => {
                    this.user.birthday = this.a + "-" + this.b + "-" + this.c;
                    this.user.address = this.d + "-" + this.e + "-" + this.g;
                    console.log("=================================================")
                    // 校验通过，提交表单
                    ly.http.post("/user/userinfo",this.user).then(resp => {
                            // 注册成功
                            this.action();
                            alert("注册成功！");
                        }).catch(e => alert("注册失败！"))
                }).catch(e => {
                    // 未登录则跳转到登录页
                    window.location.href = "/login.html?returnUrl=" + window.location.href;

                })

            },
            //加载用户个人信息
            action() {
                // 判断是否登录
                ly.http.get('/auth/verify').then(resp => {
                    ly.http.get('/user/userDK')
                        .then(resp => {
                            //赋值给data
                            this.user = resp.data;
                            let strings = resp.data.birthday.split("-");
                            let addressStr = resp.data.address.split("-");
                            this.a = strings[0];
                            this.b = strings[1];
                            this.c = strings[2];
                            this.d = addressStr[0];
                            this.e = addressStr[1];
                            this.g = addressStr[2];


                        }).catch(e => {
                        console.log('加载用户个人信息失败');
                    })
                }).catch(e => {
                    // 未登录则跳转到登录页
                    window.location.href = "/login.html?returnUrl=" + window.location.href;

                })


            },

        },
        components: {
            shortcut: () => import("/js/pages/shortcut.js")
        }
    });
</script>
<!-- 底部栏位 -->
<!--页面底部，由js动态加载-->
<div class="clearfix footer"></div>
<script type="text/javascript">$(".footer").load("foot.html");</script>
<!--页面底部END-->

</html>